Passed
Branch master (9a7ed1)
by Rafael S.
01:20
created

24-bit.js ➔ describe(ꞌ24-bit to bytesꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 37
rs 8.8571
1
2
var assert = require('assert');
3
4
describe('24-bit to bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    // 24-bit / 3 bytes 
9
    // signed
10
    it('should turn 2 signed 24-bit ints to 6 bytes (max range)', function() {
11
        assert.deepEqual(byteData.toBytes(
12
            [-8388608, 8388607], 24, {"base": 10}),
13
            [0,0,128,255,255,127]
14
        );
15
    });
16
    it('should turn 1 signed 24-bit int to 3 bytes hex (16777215)', function() {
17
        assert.deepEqual(byteData.toBytes(
18
            [16777215], 24, {"base": 16}),
19
            ["ff","ff","ff"]
20
        );
21
    });
22
    it('should turn 2 signed 24-bit ints to 6 bytes (0s)', function() {
23
        assert.deepEqual(byteData.toBytes(
24
            [0, 0], 24, {"base": 10}),
25
            [0, 0, 0, 0, 0, 0]
26
        );
27
    });
28
    it('should turn 2 unsigned 24-bit ints to 6 bytes (max range)', function() {
29
        assert.deepEqual(byteData.toBytes(
30
            [0, 16777215], 24, {"base": 10}),
31
            [0,0,0,255,255,255]
32
        );
33
    });
34
    it('should turn 2 unsigned 24-bit ints to 6 bytes (0s)', function() {
35
        assert.deepEqual(byteData.toBytes(
36
            [0, 0], 24, {"base": 10}),
37
            [0, 0, 0, 0, 0, 0]
38
        );
39
    });
40
});
41